<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body,
        html {
            height: 100%;
            padding: 0px;
            margin: 0px;
        }
    </style>
</head>

<body>
<div id="placeholder"></div>

<script type="text/javascript" src="${api}"></script>
<script th:inline="javascript">
    let config = ${config}
    console.log("===>",config)

    // the application is loaded into the browser
    let onAppReady = function () {
    }

    // the document is modified
    let onDocumentStateChange = function (event) {
    }
    // the user is trying to switch the document from the viewing into the editing mode
    let onRequestEditRights = function () {

    }

    // an error or some other specific event occurs
    let onError = function (event) {

    };

    // the document is opened for editing with the old document.key value
    let onOutdatedVersion = function (event) {

    };

    // replace the link to the document which contains a bookmark
    let replaceActionLink = function(href, linkParam) {

    }

    // the user is trying to get link for opening the document which contains a bookmark, scrolling to the bookmark position
    var onMakeActionLink = function (event) {

    }

    // the meta information of the document is changed via the meta command
    var onMetaChange = function (event) {

    }

    var onRequestInsertImage = function(event) {

    }

    var onRequestCompareFile = function() {

    }

    var onRequestMailMergeRecipients = function (event) {

    }
    var onDocumentReady = function (event) {
        console.log("加载完成")
    }
    config.events = {
        //应用程序被加载到浏览器中
        "onAppReady": onAppReady,
        //文档被修改
        "onDocumentStateChange": onDocumentStateChange,
        //用户试图通过单击 Edit current file 按钮将文档从查看模式切换到编辑模式
        'onRequestEditRights': onRequestEditRights,
        //发生错误或其他特定事件
        "onError": onError,
        //使用旧的 document.key 值打开文档进行编辑，该值用于编辑以前的文档版本并成功保存
        "onOutdatedVersion": onOutdatedVersion,
        //用户试图获取打开包含书签的文档的链接，滚动到书签位置
        "onMakeActionLink": onMakeActionLink,
        //通过meta命令更改文档的 元 信息
        "onMetaChange": onMetaChange,
        //用户尝试通过单击 存储中的图像 按钮来插入图像
        "onRequestInsertImage": onRequestInsertImage,
        // 用户试图通过单击 存储中的文档 按钮来选择要比较的文档
        "onRequestCompareFile": onRequestCompareFile,
        //用户试图通过单击 邮件合并 按钮来选择收件人数据
        "onRequestMailMergeRecipients": onRequestMailMergeRecipients,
        "onDocumentReady": onDocumentReady,
    };

    new DocsAPI.DocEditor("placeholder", config);


</script>
</body>
</html>
